package com.InetAddressDemo;


import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 网络通信
 * @Author weijingchen
 * @Date 2025/6/23 21:58
 * @Version 1.0.0
 */
public class Test01 {
    public static void main(String[] args) {

        /**
         * static InetAddress getByName(String host)  获取指定主机名的IP地址
         * String getHostName() 获取此IP地址的主机名
         * String getHostAddress() 获取此IP地址的IP地址
         */

        try {
            InetAddress byName = InetAddress.getByName("wei");
            System.out.println(byName);
            System.out.println(byName.getHostName());
            System.out.println(byName.getHostAddress());
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
